function r = logsumexp(a, b)
% Calculates the sum of two probabilities that are loged.
%
% 2012 Maarten Inja & Chiel Kooijman.

a1 = max(a, b);
b1 = min(a, b);
r = a1 + log(1 + exp(b1 - a1));
